<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <form id="myform" action="http://www.baidu.com">

    <input type="submit">

  </form>
  <script>
    // 事件对象 evnet  每个事件函数都有的一个形参
    // e.target||e.srcElement 事件源 e.clientX e.clientY  e.pageX e.pageY
    var myform = document.getElementById("myform")
    myform.onsubmit = function (e) {
      var e = e || window.event; 0
      alert("表单正在提交")
      // return false  //1阻止默认行为
      e.preventDefault();//2 阻止默认行为
    }

  </script>
</body>

</html>